﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KTXD.Entities;
using KTXD.Data;

namespace UserKTXD.Controls
{
    public partial class ControlBannerSlide : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                loadData();
        }

        private void loadData()
        {
            int TotalRows = 0;
            string WhereClause = "1=1 and IdMenuTop=7";
            TList<LoaiChuyenMuc> TList_IdLoaiChuyenMuc = DataRepository.LoaiChuyenMucProvider.GetPaged(WhereClause, "Id DESC", 0, 0, out TotalRows);
            if (TList_IdLoaiChuyenMuc.Count > 0)
            {
                //Boolean dem = true;
                //for (int i = 0; i < TList_IdLoaiChuyenMuc.Count; i++)
                //{
                //    if (dem == true)
                //    {
                //        WhereClause2 += " AND ( IdLoaiChuyenMuc='" + TList_IdLoaiChuyenMuc[i].Id + "'";
                //        dem = false;
                //    }
                //    else
                //        WhereClause2 += " OR IdLoaiChuyenMuc='" + TList_IdLoaiChuyenMuc[i].Id + "'"; 
                //}
                //WhereClause2 += ")";

                TList<ChuyenMucCapHai> TList_Ndung = DataRepository.ChuyenMucCapHaiProvider.GetPaged("IdLoaiChuyenMuc=" + TList_IdLoaiChuyenMuc[0].Id + " AND TrangThai=1", "NgayCapNhat DESC", 0, 4, out TotalRows);
                drpSlide.DataSource = TList_Ndung;
                drpSlide.DataBind();
            }
        }


        public string GetTieuDe(object Char)
        {
            string s = Char.ToString();
            return Common.ConvertToUnSign(s);
        }
    }
}